FROM golang:alpine AS builder

RUN apk add --no-cache --update git gcc rust

COPY . /src
WORKDIR /src

RUN go env -w GOPROXY=https://goproxy.cn && CGO_ENABLED=0 go build -a -ldflags "-linkmode external -extldflags -static" -o /usr/local/bin/buddhad github.com/ochinchina/supervisord

FROM scratch

COPY --from=builder /usr/local/bin/buddhad /usr/local/bin/buddhad

# docker run -it -d --name buddhad -p 9002:9002 --privileged=true -v /root/buddhad/:/root/buddhad/ buddhad-ops:latest -c /root/buddhad/buddha.yml
ENTRYPOINT ["/usr/local/bin/buddhad"]